<?php

namespace app\shopapi\model;

use think\Model;
use think\Request;
/**
 * 账单导出模型
 */
class ShopBillsExport extends Model
{

    // 表名
    protected $name = 'shop_bills_export';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = '';
    // 追加属性
    // 追加属性
    protected $append = [
        'createtime_text',
        'path_text'
    ];

    public function getCreatetimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("m-d H:i:s", $value) : $value;
    }

    public function getPathTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['path']) ? $data['path'] : '');
        $request = Request::instance();
        $domain=$request->domain();
        return $domain.'/'.$value;
    }

}
